package com.jiepos.mpos.biz.transaction.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.transaction.service.LogInsCommProfitSumService;
import com.jiepos.mpos.common.entity.App_Log_Ins_Month_Profit;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 机构佣金报表视图控制类
 * 
 * @ProjectName: [mpos]
 * @Package com.jiepos.mpos.biz.transaction.controller
 * @author 肖志伟
 * @version 1.0
 * @since 2017年10月12日 下午1:56:10
 * @history（历次修订内容、修订人、修订时间等） @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("logInsCommProfitSum")
public class LogInsCommProfitSumController extends BaseController {

	@Autowired
	private LogInsCommProfitSumService logInsCommProfitSumService;

	/**
	 * 机构分润报表列表页
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getLogInsCommProfitSumList.do")
	public ModelAndView getLogStlInsSumList(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView modelAndView = new ModelAndView(
				"/module/transaction/loginscommprofitsum/loginscommprofitsum_list");
		return super.getDetail(request, response, modelAndView);
	}

	/**
	 * 机构分润报表列表数据查询
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @param logStlMchntSumEntity
	 * @param stl_dt_start
	 * @param stl_dt_end
	 * @param custom_no
	 * @param custom_name
	 * @param custom_phone
	 * @param ins_cd
	 * @return
	 */
	@RequestMapping("/getLogInsCommProfitSumListJson.do")
	@ResponseBody
	public Map getLogStlInsSumListJson(HttpServletRequest request, HttpServletResponse response, Pagination pagination,
			App_Log_Ins_Month_Profit appLogInsMonthProfit, String stl_dt_start, String stl_dt_end, String ins_cd,
			String ins_name) {
		return logInsCommProfitSumService.getLogStlInsSumListJson(request, pagination, appLogInsMonthProfit,
				stl_dt_start, stl_dt_end, ins_cd, ins_name);
	}

	/**
	 * 机构分润报表导出
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @param logStlMchntSumEntity
	 * @param stl_dt_start
	 * @param stl_dt_end
	 * @param custom_no
	 * @param custom_name
	 * @param custom_phone
	 * @param ins_cd
	 */
	@RequestMapping("/exportLogInsCommProfitSumList.do")
	@ResponseBody
	public void exportTransactionLogs(HttpServletRequest request, HttpServletResponse response,
			App_Log_Ins_Month_Profit appLogInsMonthProfit, String stl_dt_start, String stl_dt_end, String ins_cd,
			String ins_name) {
		super.clearCookie(request, response);
		String fileName = "jigouyongjinfenrunhuizong"+stl_dt_start+"-"+stl_dt_end+".xls";
		String msg = logInsCommProfitSumService.executeSaveLogInsMonthProfitSum(fileName, request, stl_dt_start, stl_dt_end, ins_cd, ins_name);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, fileName);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}
	
	/**
	 * 获取汇总数据
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @param logStlMchntSumEntity
	 * @param stl_dt_start
	 * @param stl_dt_end
	 * @param custom_no
	 * @param custom_name
	 * @param custom_phone
	 * @param ins_cd
	 * @return
	 */
	@RequestMapping("/getLogStlMchntInfoTotal.do")
	@ResponseBody
	public Map getLogStlMchntInfoTotal(HttpServletRequest request, HttpServletResponse response,
			App_Log_Ins_Month_Profit appLogInsMonthProfit, String stl_dt_start, String stl_dt_end, String ins_cd,
			String ins_name) {
		return logInsCommProfitSumService.getLogInsCommProfitSumTotal(request, appLogInsMonthProfit, stl_dt_start,
				stl_dt_end, ins_cd, ins_name);
	}

}
